#if 0
/* Mountaniol Vsevolod */
/* This file contains default compress / decompress functions */

#include <zlib.h>
#include "updater.types.h"
#include "updater.h"
#include "updater.encode.h"
#include "updater.utils.h"
#include "updater.info.h"


/* 
	FUNCTION: default_compress
	IN: structure hostinfo, structure bufs_io, int status.
	OUT: status and filled buffer ps_buf_io->buffer_out
	DESCRIPTION: this function is default compression.
	If there no compression in hooks then this compression will be used.
	This func. get buffer ps_buf_io->buffer_in with size ps_buf_io->size_in
	and compress it into ps_buf_io->buffer_out 
	and size of compressed buffer is ps_buf_io->size_out.
	ps_host_info and i_status are not used here.

*/
INT default_compress(hostinfo_t * ps_host_info, bufs_io_t * ps_buf_io, INT i_status)
{
	INT i_rv;
	if (NULL == ps_buf_io 
		|| ps_buf_io->buffer_in == 0
		|| ps_buf_io->buffer_out == 0
		|| ps_buf_io->size_in <= 0
		|| ps_buf_io->size_out <= 0)
	{
		RETURN( - EARGUMENT );
	}
	
	i_rv = compress2 (ps_buf_io->buffer_out, 
						ps_buf_io->size_out, 
						ps_buf_io->buffer_in, 
						ps_buf_io->size_in, 
						9);

    /*	check was there error or not */
    switch ( i_rv_out )
    {
    case Z_MEM_ERROR:
	    PRINT("Compression memory error\n");
        FREE_BUFFS();
        RETURN( - ENOMEM );

    case Z_BUF_ERROR:
        PRINT("Output buffer too small\n");
        FREE_BUFFS();
        RETURN( - ENOMEM );

    default:
/*		  PRINT("out: %u\n", (unsigned int) compressed_data_size);	*/
        size_passed += not_compressed_data_size; 
        PRINT("\r[%.10u / %.10u] - %s", (unsigned int) size_passed, (unsigned int) fh->stat.st_size,  fh->path);
        break;
    }

	RETURN( OK );
}
#endif

